/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.sun.distributor.dao;

import com.sun.distributor.exceptions.SystemException;
import com.sun.distributor.objects.ProductType;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author Administrateur
 */
public class DAO_ProductType extends Abstract_DAO {

    public ProductType getProductType(int id) throws SystemException {
        try {
            Connection c = getConnection();
            Statement stmt = c.createStatement();
            ResultSet rs = stmt.executeQuery("select * from soa_Product_Type where idProduct_Type=" + id);
            ProductType prodType;

                if (rs.next()) {
                    prodType = new ProductType(rs.getInt("idProduct_Type"),rs.getString("Product_TypeName"));
                } else {
                    return null;
                }
            return prodType;
        } catch (Exception ex) {
            throw new SystemException(ex);
        }

    }
}
